class Node{
    constructor(left,right,val){
        this.left=left
        this.right=right
        this.val=val
    }
}
class Tree{
    constructor(list){
        this.list=list
        this.root=this.createTree(0)
    }
    createTree(index){
        return this.list[index]!=null?new Node(this.createTree(index*2+1),this.createTree(index*2+2),this.list[index]):null
    }
    traverseTree(node){
        return node?[node.val,null,...this.traverseTree(node.left),...this.traverseTree(node.right)]:[]
        
    }
}
testTree=new Tree([0])
result=testTree.traverseTree(testTree.root)
del=result.pop()
console.log(del===null?result:[del])